﻿using System.Security.Cryptography;
using System.Text;

namespace ExampleService.VolcanoEngine.SDK.Utils
{
    internal class Encry256
    {
        internal static string ComputeHash256(string input)
        {
            using var sha256 = SHA256.Create();
            var inputBytes = Encoding.UTF8.GetBytes(input);
            var hashedBytes = sha256.ComputeHash(inputBytes);
            return Convert.ToHexString(hashedBytes).ToLower();
        }

        internal static byte[] HmacSha256(string text, byte[] key)
        {
            return HmacSha256(Encoding.UTF8.GetBytes(text), key);
        }

        internal static byte[] HmacSha256(byte[] data, byte[] key)
        {
            using var hmac = new HMACSHA256(key);
            return hmac.ComputeHash(data);
        }

    }
}
